class MyCalendarTwo {
public:
    map<int, int> mm;
    MyCalendarTwo() {}

    bool book(int startTime, int endTime) {
        mm[startTime]++, mm[endTime]--;
        int ans = 0;
        for (auto& e : mm) {
            ans += e.second;
            if (ans > 2) {
                mm[startTime]--, mm[endTime]++;
                return false;
            }
        }
        return true;
    }
};

/**
 * Your MyCalendarTwo object will be instantiated and called as such:
 * MyCalendarTwo* obj = new MyCalendarTwo();
 * bool param_1 = obj->book(startTime,endTime);
 */